package hlhj.fhp.newslib.adapters

import android.content.Context
import android.support.v4.view.PagerAdapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import com.bumptech.glide.Glide
import hlhj.fhp.newslib.R
import hlhj.fhp.newslib.utils.GlideUtil
import java.util.ArrayList

/**
 * Created by Administrator on 2018\6\26 0026.
 */
class ImgPagerAdp(private val imgs:ArrayList<String>,private val  context: Context) :PagerAdapter() {
    override fun isViewFromObject(view: View, `object`: Any): Boolean {
     return  view==`object`
    }

    override fun instantiateItem(container: ViewGroup, position: Int): Any {
        val view = LayoutInflater.from(context).inflate(R.layout.imgsinfo_item, null)
        val imageView = view.findViewById<ImageView>(R.id.img)
        Glide.with(context).load(imgs[position]).apply(GlideUtil.loadIMGOption()).into(imageView)
        container.addView(view)
        return view
    }

    override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
//        super.destroyItem(container, position, `object`)
    }
    override fun getCount(): Int {
        return imgs.size
    }
}